package com.example.administrator.bluetooth_data_transmission.adapter;

import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.example.administrator.bluetooth_data_transmission.R;
import com.example.administrator.bluetooth_data_transmission.bean.ShowDataBean;

import java.util.ArrayList;
import java.util.List;

public class RvListAdater extends RecyclerView.Adapter<RvListAdater.MyViewHolder>{
    @NonNull

    private List<ShowDataBean> data=new ArrayList<>();

    public RvListAdater(List<ShowDataBean> data) {
        this.data=data;
    }

    public MyViewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int i) {
        View view = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.layout_data_item,viewGroup,false);
        MyViewHolder holder = new MyViewHolder(view);
        return holder;
    }

    @Override
    public void onBindViewHolder(@NonNull MyViewHolder myViewHolder, int i) {
         myViewHolder.tvDeep.setText(data.get(i).getDeep());
        myViewHolder.tvTime.setText(data.get(i).getTime());
        myViewHolder.tvDev.setText(data.get(i).getDev());
        myViewHolder.tvAzim.setText(data.get(i).getAzim());
        myViewHolder.deepTime.setText(data.get(i).getDeetTime());
    }

    @Override
    public int getItemCount() {
        return data.size();
    }

     class MyViewHolder extends RecyclerView.ViewHolder {
        TextView tvDeep;
         TextView tvTime;
         TextView tvDev;
         TextView tvAzim;
         TextView deepTime;
        public MyViewHolder(@NonNull View itemView) {
            super(itemView);
            tvDeep=itemView.findViewById(R.id.deep);
            tvTime=itemView.findViewById(R.id.time);
            tvDev=itemView.findViewById(R.id.DEV);
            tvAzim=itemView.findViewById(R.id.AZIM);
            deepTime=itemView.findViewById(R.id.Time);
        }
    }
}
